home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / utils1 / fip09.arj / SOURCE.ZIP / DISK_IO.H < prev    next >
C/C++ Source or Header  |  1993-11-17  |  4KB  |  115 lines

  1. /*
  2.     FIPS - the First nondestructive Interactive Partition Splitting program
  3.  
  4.     Module disk_io.h
  5.  
  6.     RCS - Header:
  7.     $Header: c:/daten/c/fips/source/cpp/RCS/disk_io.h 0.9.1.1 1993/11/17 17:52:27 schaefer Exp schaefer $
  8.  
  9.     Copyright (C) 1993 Arno Schaefer
  10.  
  11.     This program is free software; you can redistribute it and/or modify
  12.     it under the terms of the GNU General Public License as published by
  13.     the Free Software Foundation; either version 2 of the License, or
  14.     (at your option) any later version.
  15.  
  16.     This program is distributed in the hope that it will be useful,
  17.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.     GNU General Public License for more details.
  20.  
  21.     You should have received a copy of the GNU General Public License
  22.     along with this program; if not, write to the Free Software
  23.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  
  25.  
  26.     Report problems and direct all questions to:
  27.  
  28.     schaefer@rbg.informatik.th-darmstadt.de
  29. */
  30.  
  31. #ifndef DISK_IO_H
  32. #define DISK_IO_H
  33.  
  34. #include "types.h"
  35.  
  36. /* ----------------------------------------------------------------------- */
  37. /* Structure to hold information about the drive geometry                  */
  38. /* ----------------------------------------------------------------------- */
  39.  
  40. struct drive_geometry
  41. {
  42.     dword heads;
  43.     dword cylinders;
  44.     dword sectors;
  45. };
  46.  
  47. /* ----------------------------------------------------------------------- */
  48. /* Physical_sector_no holds and calculates physical sector number (Head,   */
  49. /* Cylinder, Sector). Number is calculated on initialization. Log_sector   */
  50. /* is absolute logical sector number (0 = master boot record). Usage:      */
  51. /* physical_sector_no mbr (0,geometry);                                    */
  52. /* physical_sector_no mbr (0,0,1);                                         */
  53. /* ----------------------------------------------------------------------- */
  54.  
  55. struct physical_sector_no
  56. {
  57.     dword head;
  58.     dword cylinder;
  59.     dword sector;
  60.  
  61.     physical_sector_no (dword log_sector,const drive_geometry &geometry);
  62.     physical_sector_no (dword head,dword cylinder,dword sector)
  63.     {
  64.         physical_sector_no::head = head;
  65.         physical_sector_no::cylinder = cylinder;
  66.         physical_sector_no::sector = sector;
  67.     }
  68. };
  69.  
  70. /* ----------------------------------------------------------------------- */
  71. /* Low level structure physical_drive, contains drive number and geometry. */
  72. /* Geometry is determined on initialization, errorcode contains error      */
  73. /* number after call to get_geometry() and reset().                        */
  74. /* Initialization requires number (ex.: physical_drive c(0x80);).          */
  75. /* ----------------------------------------------------------------------- */
  76.  
  77. class physical_drive
  78. {
  79. protected:
  80.     virtual void get_geometry (void);
  81. public:
  82.     int number;
  83.     int errorcode;
  84.     drive_geometry geometry;
  85.     virtual void reset (void);
  86.  
  87.     physical_drive (int number);
  88.     physical_drive (physical_drive &pd);
  89.     void operator= (physical_drive &pd);
  90. };
  91.  
  92. /* ----------------------------------------------------------------------- */
  93. /* Structure sector - contains data and low level read/write routines.     */
  94. /* Read and write are called max. 3 times in case of failure, return code  */
  95. /* contains 0 if successful. Sector CRC is verified after write.           */
  96. /* Sector is absolute logical sector number (0 = master boot record).      */
  97. /* ----------------------------------------------------------------------- */
  98.  
  99. struct sector
  100. {
  101.     byte data[512];
  102.     int read (physical_drive *drive,dword sector);
  103.     int write (physical_drive *drive,dword sector);
  104. };
  105.  
  106. /* ----------------------------------------------------------------------- */
  107. /* Prototype for bios call get_disk_type - returns 0 if drive not present. */
  108. /* Valid drive numbers: 0 - 255, result: 1 - floppy without disk change    */
  109. /* detection, 2 - floppy with disk change detection, 3 - harddisk          */
  110. /* ----------------------------------------------------------------------- */
  111.  
  112. int get_disk_type (int drive_number);
  113.  
  114. #endif
  115.